Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to change item tag #43

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Conversation

Eseperio
Copy link

With this modification user can change the name of the tag used to wrap the notification.
It is an optional parameter in order to keep BC.

Also there is another little tweak. When there aren´t notifications counters now displays nothing instead 0.

This allows the user hide a badge when there are not notifications by using :empty css property.
If you need to keep 0 number then use css rule .counterclass:empty:before { content: "0"}

The behavior of hiding a badge when it is empty is used by almost all admin templates.

The wrong use of data as selector requires data attributes to be set in a manual way, instead using data parameter.
The correct use for the counter when there aren´t notifications is not display 0, is display empty value. Then you can automatically hide a badge using css rule `:empty`. Also you can set the number zero using `:empty:before { content: "0" }`
@drsdre
Copy link
Collaborator

drsdre commented Oct 13, 2017

It's not clear to me why the encapsulating tag should be configurable on each message. Can you give an example how you use this?

Copy link
Owner

@machour machour left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this PR @Eseperio, looks solid.
Left some comments about enhancements to be made 👍


html = $(self.opts.tag, {
class: "notification notification-" + object['type'] + " "+(object.seen ? 'notification-seen' : 'notification-unseen'),
"data-route":object['url'],
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use the object.url form, with an extra space before 'object'
single quotes instead of double quotes

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, i don´t know why i used brackets in that object. Is a mistake

@@ -205,6 +210,7 @@ public function registerAssets()
'pollSeen' => !!$this->pollSeen,
'pollInterval' => Html::encode($this->pollInterval),
'counters' => $this->counters,
'tag' => Html::beginTag($this->tag)
];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of the user providing only the tag name, shouldn't we enable him to pass also attributes?
Maybe move the processing in the Javascript, I don't like that we're calling Yii just to get '<' '>'

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a little modification. I have seen that javascript template can be impoved in many ways. I have a few ideas, but now i´m busy with other projects. When i have time i´ll try to do it.

Copy link
Author

@Eseperio Eseperio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used .property instead [property]

@Eseperio
Copy link
Author

@drsdre See #42

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants